package com.shangsheng.security;

import com.shangsheng.entity.UserProfile;
import com.shangsheng.service.UserServiceProfile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class RoleToUserProfileConverter implements Converter<Object,UserProfile> {

    @Autowired
    UserServiceProfile userServiceProfile;

    @Override
    public UserProfile convert(Object object) {
        int id = Integer.parseInt((String) object);
        UserProfile userProfile=userServiceProfile.findById(id);
        System.out.println("RoleToUserProfileConverter userProfile:"+userProfile);
        return userProfile;
    }

//
//    @Override
//    public UserProfile convert(Object object) {
//        String id =((String) object);
//        UserProfile userProfile=userServiceProfile.findByType(id);
//        System.out.println("RoleToUserProfileConverter userProfile:"+userProfile);
//        return userProfile;
//    }

}
